<?php

/**
 * @copyright 2012
 */
require_once("db_common.php");
require_once ("XMLUtils.php");
class Account
{
    
    function Init($accountid)
    {
        $sql = "select account_name,account_id,account_money from account where account_id = '$accountid'";
    
        if($query = mysql_query($sql))
        {
            $row = mysql_fetch_array($query);
            //print_r($row);
            $this->name = $row['account_name'];
            $this->id = $row['account_id'];
            $this->money = $row['account_money'];
        } else 
        {
            echo "accountid = " + $accountid;
            output_mysqlerror();
        }
    }
    
    function Update()
    {
        if($this->id){
            $sql = "update account set account_name = '$this->name',account_money = '$this->money'
                        where account_id = '$this->id'";
            if($query = mysql_query($sql))
            {
                
            } else 
            {
                  echo "id = " + $accountid;
                  output_mysqlerror();
            }
        } else 
        {
            echo "$accountid is empty In Account::Update";
        }
    }
    
    function GetXMLNode($doc)
    {
        $s = $doc->createElement("account");
       // $r->appendChild($s);
  
        AppendNewTextNode($doc, "name", $this->name, $s);
        AppendNewTextNode($doc, "id", $this->id, $s);
        AppendNewTextNode($doc, "money", $this->money, $s);
        
        return $s;
    }
    
    var $id;
    var $money;
    var $name;
    
}



?>